home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / Intelligent classes 1.0 / CIntelligentPanorama.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.9 KB  |  108 lines  |  [TEXT/KAHL]

  1. /****
  2.  *    CIntelligentPanorama.c
  3.  *
  4.  *    This class makes the Panorama a little more intelligent.
  5.  *
  6.  *    Copyright © 1993 Quipus, by Mårten Sörliden.  All rights reserved.
  7.  *
  8.  ****/
  9.  
  10. #include <Global.h>
  11. #include <CIntelligentPanorama.h>
  12. #include <CIntelligentScrollPane.h>
  13.  
  14.  
  15. /** Construction and destruction methods **/
  16.  
  17. void CIntelligentPanorama::IIntelligentPanorama(CView *anEnclosure, CBureaucrat *aSupervisor,
  18.                             short aWidth, short aHeight,
  19.                             short aHEncl, short aVEncl,
  20.                             SizingOption aHSizing, SizingOption aVSizing)
  21. {
  22.     IPanorama(anEnclosure, aSupervisor, aWidth, aHeight,
  23.                     aHEncl, aVEncl, aHSizing, aVSizing);
  24.     UseLongCoordinates(TRUE);
  25.     autoScrolled = FALSE;
  26.     autoRefresh = FALSE;        // From CPane 
  27. }
  28.  
  29. void CIntelligentPanorama::Dispose(void)
  30. {
  31.     LongRect theBounds;
  32.  
  33.     if (itsScrollPane)
  34.         if (member(itsScrollPane, CIntelligentScrollPane)) {
  35.             SetLongRect(&theBounds, 0L, 0L, 0L, 0L);
  36.             SetBounds(&theBounds);
  37.         }
  38.     inherited::Dispose();
  39. }
  40.  
  41.  
  42. /** Accessing methods **/
  43.  
  44. /* Override */
  45. void    CIntelligentPanorama::SetBounds(LongRect *aBounds)
  46. {
  47.     long hDelta = 0L;
  48.     long vDelta = 0L;
  49.  
  50.     if ((aBounds->right < frame.right) && (aBounds->left < frame.left))
  51.         hDelta = -Min(frame.right - aBounds->right, frame.left - aBounds->left);
  52.     else if ((aBounds->right > frame.right) && (aBounds->left > frame.left))
  53.         hDelta = Min(aBounds->right - frame.right, aBounds->left - frame.left);
  54.     if ((aBounds->top < frame.top) && (aBounds->bottom < frame.bottom))
  55.         vDelta = -Min(frame.top - aBounds->top, frame.bottom - aBounds->bottom);
  56.     else if ((aBounds->top > frame.top) && (aBounds->bottom > frame.bottom))
  57.         vDelta = Min(aBounds->top - frame.top, aBounds->bottom - frame.bottom);
  58.     if (hDelta || vDelta)
  59.         inherited::Scroll(hDelta, vDelta, TRUE);
  60.     inherited::SetBounds(aBounds);
  61.     if (itsScrollPane) {
  62.         itsScrollPane->AdjustScrollMax();
  63.         itsScrollPane->Calibrate();
  64.     }
  65. }
  66.  
  67.  
  68. /** Drawing methods **/
  69.  
  70. /* Override */
  71. void    CIntelligentPanorama::ResizeFrame(register Rect *delta)
  72. {
  73.     long hDelta = 0L;
  74.     long vDelta = 0L;
  75.  
  76.     inherited::ResizeFrame(delta);
  77.     if ((delta->right > 0L) && (frame.right > bounds.right) && (frame.left > bounds.left)) {
  78.         hDelta = Min(delta->right, frame.right - bounds.right);
  79.         hDelta = Min(hDelta, frame.left - bounds.left);
  80.     }
  81.     if ((delta->bottom > 0L) && (frame.bottom > bounds.bottom) && (frame.top > bounds.top)) {
  82.         vDelta = Min(delta->bottom, frame.bottom - bounds.bottom);
  83.         vDelta = Min(vDelta, frame.top - bounds.top);
  84.     }
  85.     if (hDelta || vDelta) {
  86.         autoScrolled = TRUE;
  87.         CPanorama::Scroll(-hDelta, -vDelta, FALSE);
  88.     }
  89. }
  90.  
  91.  
  92. /** Size and location methods **/
  93.  
  94. /* Override */
  95. void CIntelligentPanorama::ChangeSize(register Rect *delta, Boolean redraw)
  96. {
  97.     LongRect    oldAperture = aperture;
  98.     Rect         tmp;
  99.     
  100.     autoScrolled = FALSE;        // Might be changed by ResizeFrame
  101.     inherited::ChangeSize(delta, redraw);
  102.     if (autoScrolled)
  103.         if (SectLongRect(&aperture, &oldAperture, &oldAperture)) {
  104.             FrameToQDR( &oldAperture, &tmp);
  105.             InvalRect(&tmp);
  106.         }
  107. }
  108.